﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TSL
{
	/// <summary>
	/// Interaction logic for AuthenWindow.xaml
	/// </summary>
	public partial class AuthenWindow : Window
	{
        private String adminPass = "admin";
        private String instructorPass = "teacher";
        private String targetWindow;
		public AuthenWindow()
		{
			this.InitializeComponent();
		}

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (targetWindow.Equals("record"))
            {
                if (passBox.Password.Equals(adminPass) || passBox.Password.Equals(instructorPass))
                {
                    var recWindows = new MainWindow();
                    recWindows.Show();
                    this.Close();
                }
                else
                {
                    notiText.Content = "รหัสยืนยันผิดพลาด กรุณากรอกรหัสที่ถูกต้อง";
                }
            }
            else if (targetWindow.Equals("train"))
            {
                if (passBox.Password.Equals(adminPass))
                {
                    var testWindow = new TestingWindos();
                    testWindow.Show();
                    this.Close();
                }
                else if (passBox.Password.Equals(instructorPass))
                {
                    notiText.Content = "คุณไม่มีสิทธิเข้าถึงส่วนนี้";
                }
                else
                {
                    notiText.Content = "รหัสยืนยันผิดพลาด กรุณากรอกรหัสที่ถูกต้อง";
                }
            }
        }

        public void setTargetWindow(String target)
        {
            targetWindow = target;
        }

        private void backButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	var mainmenu = new MainMenu();
            mainmenu.Show();
            this.Close();
        }
	}
}